983bce
@@ -138,7 +138,7 @@
public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
 			MediaType mediaType = headers.getContentType();
 			Assert.state(mediaType != null, "No content type set");
 
-			int length = Math.toIntExact(headers.getContentLength());
+			int length = getContentLength(headers);
 			Charset charset = Optional.ofNullable(mediaType.getCharset()).orElse(StandardCharsets.UTF_8);
 			MultipartContext context = new MultipartContext(mediaType.toString(), length, charset.name());
 
@@ -176,7 +176,12 @@
public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
 					listener.onError("Exception thrown while closing the parser", ex);
 				}
 			});
+		}
 
+		private int getContentLength(HttpHeaders headers) {
+			// Until this is fixed https://github.com/synchronoss/nio-multipart/issues/10
+			long length = headers.getContentLength();
+			return (int) length == length ? (int) length : -1;
 		}
 	}
 
